package com.mrzhou.system.service.impl;

import com.mrzhou.system.entity.Menu;
import com.mrzhou.core.tool.constants.CloudConstant;
import com.mrzhou.mybatis.base.BaseServiceImpl;
import com.mrzhou.system.mapper.MenuMapper;
import com.mrzhou.system.service.IMenuService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, Menu> implements IMenuService {

    public boolean submit(Menu menu) {
        if(menu.getParentId() == null && menu.getId() == null) {
            menu.setParentId(CloudConstant.TOP_PATENT_ID);
        }
        menu.setIsDelete(CloudConstant.DEFAULT_NOT_DELETE);
        return saveOrUpdate(menu);
    }

    public List<Menu> treeMenuListByParentId(Long parentId) {
        return this.baseMapper.treeMenuListByParentId(parentId);
    }

}
